package com.laker.admin.module.excel.controller;

import com.laker.admin.framework.aop.Metrics;
import com.laker.admin.framework.model.Response;
import com.laker.admin.module.excel.entity.ExcelDataCmd;
import com.laker.admin.module.excel.facade.ExcelDataFacade;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 数据源
 * </p>
 *
 * @author nihongxin
 * @since 2021-12-08
 */
@RestController
@RequestMapping("/excelData")
@Metrics
public class ExcelDataController {

    @Autowired
    private ExcelDataFacade excelDataFacade;

    @PostMapping("/save")
    @ApiOperation(value = "保存集合数据")
    public Response save(@RequestBody ExcelDataCmd excelDataCmd) {
        return excelDataFacade.save(excelDataCmd);
    }

    @PostMapping("/saveExcelData")
    @ApiOperation(value = "保存单个数据")
    public Response saveExcelData(@RequestBody ExcelDataCmd excelDataCmd) {
        return excelDataFacade.saveExcelData(excelDataCmd);
    }

    @PostMapping("/getExcelDataList")
    @ApiOperation(value = "获取数据")
    public Response getExcelDataList(@RequestBody ExcelDataCmd excelDataCmd) {
        return excelDataFacade.getExcelDataList(excelDataCmd);
    }

    @ApiOperation(value = "根据excelTemplateId获取绑定的数据")
    @GetMapping(value = "/getByTemplateId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "excelTemplateId", dataType = "Long", required = true, value = "excelTemplateId", paramType = "form")
    })
    public Response getByTemplateId(Long excelTemplateId) {
        return excelDataFacade.getByTemplateId(excelTemplateId);
    }

}